* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  font-family: '楷体';
  font-size: 18px;
}

div {
  height: 40px;
  width: 810px;
  margin: 50px auto;
  background: linear-gradient(#cccccc, #8f8f8f);
  /*水平时添加  position: relative; */
}

div ul li {
  list-style: none;
  float: left;
  border-left: 0.5px solid white;
  border-right: 0.5px solid white;
}

div ul li a {
  text-decoration: none;
  color: black;
  display: block;
  width: 100px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  transition: all 1s;
}

div ul li a:hover {
  background-color: black;
  color: white;
}

div ul li ol {
  display: none;
  position: absolute;
  /* left: 0; */
  width: 100px;
  /* 水平时，注释掉 width:100px; 加上left:0; 给父元素div加上 position:relative;*/
  background: linear-gradient(#cccccc, #8f8f8f);
}

div ul li:hover ol {
  display: block;
}

.active {
  background-color: black;
  color: white;
}